/**
 * 初始化对象
 * @param obj //要初始化的对象
 * @param defaultValue //默认值
 */
export function initObj(obj: any, defaultValue?: any) {
    Object.keys(obj).forEach((key: string) => {
        var val = obj[key]
        if (!val) {
            return;
        }
        var typeName = obj[key].constructor.name;
        switch (typeName) {
            case Number.name:
                obj[key] = 0;
                break;
            case String.name:
                obj[key] = '';
                break;
            case Array.name:
                obj[key] = [];
                break;
            case Boolean.name:
                obj[key] = false;
                break;
            default:
                obj[key] = undefined;
                break;
        }
    });
    if (defaultValue) {
        Object.assign(obj, defaultValue)
    }
}


